﻿///Arrow.as 该类为箭头类
//vesion 1.0
//author 夏天的树人
package org.summerTree.graphics
{
	import flash.geom.Point;
	import flash.display.Shape;
	public class Arrow extends Base  
	{
		//private var START_POINT:Point;
		private var shape:Shape=new Shape();
		public function Arrow()
		{

		}
		override public function clone():*
		{
			return new Arrow();
		}
		//创建箭头
		/*radius 轴径
		 *fillColor 填充颜色
		 *alpha 透明度
		 */		
		public function CreatArrow(radius:Number,fillColor:uint=0xffffff,alpha:Number=1):void
		{
			if(radius<0) return ;
			
			var list:Array=new Array();
			this.graphics.lineStyle(1,color);
			this.graphics.beginFill(fillColor,alpha);
			
			for(var i:int=-1;i<2;i++)
			{
			   var point:Point=Point.polar(radius,i*2*Math.PI/3);
			   list.push(point); 			
			}
			var len:int=list.length;
			this.graphics.moveTo(0,0);
			for(var j:int=0;j<3;j++)
			{    
				drawPoint(list[j]);			 
			}
			this.graphics.lineTo(0,0); 
			this.graphics.endFill();						
		}
		
		//添加箭头身体
		/* Height 身体
		 * thickness 线条长度
		 * fillcolor 填充颜色
		 * alpha 透明度
		 */
		public function addArrowBody(Height:Number,thickness:Number=1,fillcolor=0x000000,alpha=1):void
		{
			addChild(shape);
			shape.graphics.lineStyle(thickness,fillcolor,alpha);
			shape.graphics.moveTo(0,0);
			
			shape.graphics.lineTo(0,Height);
			shape.rotation=this.rotation+90;
		}
		
		
		private function drawPoint(point:Point):void
		{			 
			this.graphics.lineTo(point.x,point.y);
		}		
		override public function clear():void
		{
			shape.graphics.clear();
			this.graphics.clear();
		}
	}
	
	
}